package com.xlfc.cluster.loadBalance;

import com.xlfc.common.config.RpcRequest;

import java.util.List;

//实现轮询负载均衡
public class PollingLoadBalance extends AbstractLoadBalance {
    @Override
    protected String doSelect(List<String> serviceAddresses, RpcRequest rpcRequest) {
        if(index>=serviceAddresses.size()){
            index-=serviceAddresses.size();
        }
        return serviceAddresses.get(index++);
    }
    static volatile int index=0;
}
